﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.IO.IsolatedStorage;
using System.Xml;
using System.Xml.Linq;
namespace BeatingMole
{
    class CBusSaveGame
    {
        #region "Variable"
        ContentManager _Content;
        CInfoLoadAndSaveGame InfoLoadAndSaveGame;
        int _curTime;
        IsolatedStorageFile IsoFiles = IsolatedStorageFile.GetUserStoreForApplication();
        #endregion

        #region "Properties"
        public int CurTime
        {
            set { _curTime = value; }
            get { return _curTime; }
        }
        #endregion

        #region "Constructor"
        public CBusSaveGame(ContentManager content)
        {
            _Content = content;
            InfoLoadAndSaveGame = new CInfoLoadAndSaveGame(_Content);
        }
        #endregion

        public int GetTime()
        {
            return CurTime;
        }

        #region "Method"
        public void Update(GameTime gameTime)
        {
            if (new Rectangle(Mouse.GetState().X, Mouse.GetState().Y, 1, 1).Intersects(InfoLoadAndSaveGame.RecBtnSaveGame))
            {
                InfoLoadAndSaveGame.XmlSaveGame.Player.Name = CGlobalVariable.InfoPlayer.Name;
                InfoLoadAndSaveGame.XmlSaveGame.Score = CGlobalVariable.InfoPlayer.Score;
                InfoLoadAndSaveGame.XmlSaveGame.Time = GetTime();

                if (Directory.Exists(@"/SaveGame"))
                {
                    XDocument _save = XDocument.Load("Resource/Xml/SaveGame");
                }
                else
                {
                    Directory.CreateDirectory(@"/SaveGame");
                }

            }
        }
        public void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(InfoLoadAndSaveGame.BtnSaveGame, new Vector2(575, 0), Color.White);
        }
        #endregion

    }
}
